package com.glory.erp.invoice.orderdetail.action;

import java.util.List;

import com.glory.erp.invoice.orderdetail.service.OrderDetailService;
import com.glory.erp.invoice.orderdetail.bean.OrderDetail;
import com.glory.erp.invoice.orderdetail.bean.OrderDetailQuery;
import com.glory.erp.auth.base.BaseAction;

public class OrderDetailAction extends BaseAction{
	
	public OrderDetail orderDetail = new OrderDetail();
	public OrderDetailQuery orderDetailQuery = new OrderDetailQuery();
	
	public OrderDetail getOrderDetail() {
		return orderDetail;
	}

	private OrderDetailService orderDetailService;
	
	public void setOrderDetailService(OrderDetailService orderDetailService) {
		this.orderDetailService = orderDetailService;
	}

	//列表
	public String list(){
		setDataTotal(orderDetailService.getCount(orderDetailQuery));
		List<OrderDetail> orderDetailList = orderDetailService.findAll(orderDetailQuery,pageNum,pageCount);
		put("orderDetailList", orderDetailList);
		return LIST;
	}

	//到添加
	public String addView(){
		if(orderDetail.getUuid()!=null){
			orderDetail = orderDetailService.findById(orderDetail.getUuid());
		}
		return ADD;
	}

	//添加
	public String saveAndUpdate(){
		if(orderDetail.getUuid() == null){
			orderDetailService.save(orderDetail);
		}else{
			orderDetailService.update(orderDetail);
		}
		return TO_LIST;
	}

	//删除
	public String delete(){
		orderDetailService.delete(orderDetail);
		return TO_LIST;
	}
	
	public String ajaxGetSurplus(){
		orderDetail = orderDetailService.findById(orderDetail.getUuid());
		return "ajaxGetSurplus";
	}
}